<template>
	<!-- 添加弹框 -->
	<el-dialog title="" visible :show-close="false" :modal-append-to-body="false" size="tiny" class="wrap">
		<i class="el-icon-close close" @click="cancel" style="color: white;z-index: 99;"></i>
	    <div class="bt">老师课时添加管理</div>
	       <el-form label-width="100px" class="form">
		<el-form-item label="老师名称">
 			<el-select v-model="vlsid" class="select-block">
				<el-option :label="v.mc" :value="v.id" v-for="v in comboxlist"></el-option>
			</el-select>
 	</el-form-item>
		<el-form-item label="上课总数">
 				<el-input v-model="vskzs"  placeholder="请输入上课总数" class="select-block"></el-input>
 		</el-form-item>
		</el-form>
		<el-button type="info" class="submit" @click="submit">保存</el-button>
	</el-dialog>
</template> 
<script type="text/javascript">
	import qs from 'qs'
	export default {
		data() {
			return {
				vlsid: '',
				vskzs: '',
				comboxlist: [],
				dialogTableVisible: true
			}
		},
		created() {
			this.getcomboxlist();
		},

		methods: {
			submit() {
				//检测
				this.$store.state.loading = true;
			   if(!this.vlsid) {
					this.$message.warning('请选择老师名称');
					this.$store.state.loading = false;
					return;
				} 
				var logininfo = JSON.parse(localStorage.logininfo);
				var params3 = qs.stringify({
					lsid: this.vlsid,
					skzs: this.vskzs,
					xxid:logininfo.xxid
				});
				//执行
				this.axios.post(this.$store.state.api + 'lsks/insert', params3)
					.then(res => {
						if(res.data.code == 1) {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						} else {
							this.$emit('close', { type: 'add', cancel: false });
							this.$store.state.loading = false;
						}
					}).catch(res => {
						this.$message.warning("服务器繁忙，请重试");
						//this.$emit('close', { type: 'add', cancel: false });
						this.$store.state.loading = false;
					})
			},
			cancel() {
				this.$emit('close', { type: 'add', cancel: true })
			},
			getcomboxlist() {
				var logininfo = JSON.parse(localStorage.logininfo);
              this.searchLoading = true;
             var params2 = qs.stringify({
                  yhid: logininfo.id,
						xxid: logininfo.xxid
               })
             //执行
                 this.axios.post(this.$store.state.api + 'ls/getlslist',  params2 )
                 .then(res => {
                 console.log(res)
                  console.log(res)
					let data = res.data.data;
					let list = data.list;
					this.comboxlist = list;
					console.log(this.comboxlist)
                 }).catch(res => {
					 console.log(res)
					this.searchLoading = false;
				})				
			}
		}
	}
</script>
<style lang="less" scoped>
	.wrap {
		.bt{
			position: absolute;
			width: 100%;
			height: 50px;
			margin: 0 auto;
			top:0;
			left:0;
			background: #50BFFF;
			margin-bottom: 20px;
			color:white;
			text-align:left;
			line-height: 50px;
			font-size: 17px;
			padding-left: 15px;
		}
		.select-block {
	 		display: block;
	 		width: 85%;
 	    }
 	    .form {
			text-align: center;
			margin-top:20px;
	    }
		.input {
			display: inline-block;
		}
		.submit {
			width: 120px;
			display: block;
			margin: 0 auto;
			margin-top: 20px;
		}
	}
</style>
